CARME-M4 BSP
V1.5
|
Drivers for the CAN interface. Uses the SJA1000 CAN controller on the CARME motherboard. More...
Go to the source code of this file.
Data Structures | |
struct | _CARME_CAN_MESSAGE |
This struct encapsulates a CAN message. More... | |
struct | _CARME_CAN_ACCEPTANCE_FILTER |
Information about the acceptance filter. More... | |
Typedefs | |
typedef struct _CARME_CAN_MESSAGE | CARME_CAN_MESSAGE |
This struct encapsulates a CAN message. | |
typedef struct _CARME_CAN_ACCEPTANCE_FILTER | CARME_CAN_ACCEPTANCE_FILTER |
Information about the acceptance filter. More... | |
typedef void(* | IRQ_CALLBACK) () |
Pointer to a function. | |
Enumerations | |
enum | CARME_CAN_IRQ_CALLBACKS { CARME_CAN_IRQID_RX_INTERRUPT = 0, CARME_CAN_IRQID_TX_INTERRUPT, CARME_CAN_IRQID_ERROR_INTERRUPT, CARME_CAN_IRQID_DATAOVERFLOW_INTERRUPT, CARME_CAN_IRQID_WAKEUP_INTERRUPT, CARME_CAN_IRQID_PASSIVE_INTERRUPT, CARME_CAN_IRQID_ARITRATION_LOST_INTERRUPT, CARME_CAN_IRQID_BUS_ERROR_INTERRUPT, CARME_CAN_IRQID_COUNT } |
Interrupt sources of the CAN-Controller. More... | |
enum | CARME_CAN_ACCEPTANCE_FILTER_MODE { MODE_SINGLE = 1, MODE_DUAL = 2 } |
Acceptance filter modes. More... | |
Functions | |
void | CARME_CAN_Init (uint32_t baud, uint8_t flags) |
Initialize GPIOs and the CAN-Controller. More... | |
void | CARME_CAN_InitI (uint32_t baud, uint8_t flags, uint32_t interrupts) |
Initialize GPIOs and the CAN-Controller. More... | |
ERROR_CODES | CARME_CAN_Write (CARME_CAN_MESSAGE *txMsg) |
Sends a CAN-Messsage over the CAN-Bus. More... | |
ERROR_CODES | CARME_CAN_Read (CARME_CAN_MESSAGE *rxMsg) |
Reads a CAN-Message from the Receive-Buffer. If no message is in the buffer, the function returns CARME_ERROR_CAN_ERROR_RXFIFO_EMPTY. More... | |
void | CARME_CAN_Interrupt_Handler (void) |
This function will be called from the Interrupt-Handler on a CAN-Interrupt. If it was not the EXTI Line from the CAN controller, then the functions MyEXTI9_5_IRQHandler is called. More... | |
void | CARME_CAN_RegisterIRQCallback (enum CARME_CAN_IRQ_CALLBACKS id, IRQ_CALLBACK pIRQCallback) |
Registers a callback function. Callback functions are called in Interruptmode. Use this function after CARME_CAN_init() or CARME_CAN_initI(). More... | |
void | CARME_CAN_UnregisterIRQCallback (enum CARME_CAN_IRQ_CALLBACKS id) |
Unregisters a callback function. Callback functions are called in Interruptmode. More... | |
ERROR_CODES | CARME_CAN_SetMode (uint8_t flags) |
Change operating mode from the CAN-Controller. More... | |
ERROR_CODES | CARME_CAN_SetBaudrate (uint32_t baud) |
Set the baudrate for the CAN-Communication. More... | |
ERROR_CODES | CARME_CAN_SetAcceptaceFilter (CARME_CAN_ACCEPTANCE_FILTER *af) |
ACCEPTANCE FILTER With the help of the acceptance filter the CAN controller is able to allow passing of received messages to the RXFIFO only when the identifier bits of the received message are equal to the predefined ones within the acceptance filter registers. The acceptance filter is defined by the Acceptance Code Registers (ACRn) and the Acceptance Mask Registers (AMRn). The bit patterns of messages to be received are defined within the acceptance code registers. The corresponding acceptance mask registers allow to define certain bit positions to be 'don't care'. Two different filter modes are selectable within the mode register: More... | |
ERROR_CODES | CARME_CAN_GetAcceptaceFilter (CARME_CAN_ACCEPTANCE_FILTER *af) |
Get the Acceptance Filter settings. More... | |
static void | CARME_CAN_Write_Register (uint8_t registerAddress, uint8_t val) |
Write a value in a SJA1000 register. More... | |
static uint8_t | CARME_CAN_Read_Register (uint8_t registerAddress) |
Reads a value from a SJA1000 register. More... | |
static uint8_t | CARME_CAN_IsBusOn (void) |
Returns 1 if the CAN Controller is involved in bus activities The Function checks the BS-bit in the status register of the SJA1000. More... | |
static uint8_t | CARME_CAN_IsDataOverrun (void) |
Returns 1 if an data overrun occurred The Function checks the DOS-bit in the status register of the SJA1000. More... | |
static uint8_t | CARME_CAN_IsError (void) |
Returns 1 if at least one of the error counters has reached or exceeded the value in the Error Warning Limit Register. The Function checks the ES-bit in the status register of the SJA1000. More... | |
static void | CARME_CAN_ClearDataOverrun (void) |
Clear Data-Overrun-Bit in the status register of the SJA1000. | |
static void | CARME_CAN_AbortTransmisssion (void) |
Cancel a pending transmission request. | |
static ERROR_CODES | CARME_CAN_SetErrorWarningLimit (uint8_t limit) |
Set the value of the Error Warning Limit Register. The content can only be changed in reset mode. More... | |
static void | CARME_CAN_GetErrorWarningLimit (uint8_t *limit) |
Get the value of the Error Warning Limit Register. More... | |
static void | CARME_CAN_GetRxErrCount (uint8_t *count) |
Get the value of the RX Error Count Register. More... | |
static void | CARME_CAN_GetTxErrCount (uint8_t *count) |
Get the value of the TX Error Count Register. More... | |
static void | CARME_CAN_GetArbitrationLostCapture (uint8_t *alc) |
Get the value of the TX Error Count Register. More... | |
static void | CARME_CAN_GetErrorCodeCapture (uint8_t *ecc) |
Get the value of the TX Error Count Register. More... | |
Variables | |
static __IO uint8_t * | SJA1000_CMD = (__IO uint8_t *) (FSMC_CAN_BASE) |
static __IO uint8_t * | SJA1000_DATA = (__IO uint8_t *) (FSMC_CAN_BASE + 8) |
Drivers for the CAN interface. Uses the SJA1000 CAN controller on the CARME motherboard.
This software can be used by students and other personal of the Bern University of Applied Sciences under the terms of the MIT license. For other persons this software is under the terms of the GNU General Public License version 2.
Copyright © 2013, Bern University of Applied Sciences. All rights reserved.
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 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Definition in file can.h.