Skip to content
Snippets Groups Projects
Select Git revision
  • 064b2b470139c1db76c498f74fcd626e54cdd1e9
  • main default protected
  • tuxcoder_dome
  • tuxcoder_fix_captouch
  • crates-reorga
  • wifi
  • test-badgenet
7 results

README.md

Blame
  • Forked from flow3r / flow3-rs
    Source project has a limited visibility.
    can.c 16.08 KiB
    /*
     * This file is part of the Micro Python project, http://micropython.org/
     *
     * The MIT License (MIT)
     *
     * Copyright (c) 2014 Damien P. George
     *
     * 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 <stdio.h>
    #include <string.h>
    #include <stdarg.h>
    #include <errno.h>
    
    #include "mpconfig.h"
    #include "nlr.h"
    #include "misc.h"
    #include "qstr.h"
    #include "obj.h"
    #include "objtuple.h"
    #include "runtime.h"
    #include "bufhelper.h"
    #include "can.h"
    #include "pybioctl.h"
    #include MICROPY_HAL_H
    
    #if MICROPY_HW_ENABLE_CAN
    
    /// \moduleref pyb
    /// \class CAN - controller area network communication bus
    ///
    /// CAN implements the standard CAN communications protocol.  At
    /// the physical level it consists of 2 lines: RX and TX.  Note that
    /// to connect the pyboard to a CAN bus you must use a CAN transceiver
    /// to convert the CAN logic signals from the pyboard to the correct
    /// voltage levels on the bus.
    ///
    /// Note that this driver does not yet support filter configuration
    /// (it defaults to a single filter that lets through all messages),
    /// or bus timing configuration (except for setting the prescaler).
    ///
    /// Example usage (works without anything connected):
    ///
    ///     from pyb import CAN
    ///     can = pyb.CAN(1, pyb.CAN.LOOPBACK)
    ///     can.send('message!', 123)   # send message with id 123
    ///     can.recv(0)                 # receive message on FIFO 0
    
    typedef struct _pyb_can_obj_t {
        mp_obj_base_t base;
        mp_uint_t can_id : 8;
        bool is_enabled : 1;
        bool extframe : 1;