mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
[SAM] updating CAN transceiver conforming to Arduino API
This commit is contained in:
parent
d25921692a
commit
ecfea6da9f
@ -1,31 +1,21 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "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 ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2013 Arduino. All right reserved.
|
||||
|
||||
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 St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
@ -46,10 +36,7 @@
|
||||
*/
|
||||
extern uint32_t SN65HVD234_Init( SSN65HVD234_Data* pComponent )
|
||||
{
|
||||
pComponent->pPIO_Rs=NULL ;
|
||||
pComponent->dwPin_Rs=0u ;
|
||||
|
||||
pComponent->pPIO_EN=NULL ;
|
||||
pComponent->dwPin_EN=0u ;
|
||||
|
||||
return 0u ;
|
||||
@ -64,12 +51,11 @@ extern uint32_t SN65HVD234_Init( SSN65HVD234_Data* pComponent )
|
||||
*
|
||||
* \return 0 if OK
|
||||
*/
|
||||
extern uint32_t SN65HVD234_SetRs( SSN65HVD234_Data* pComponent, Pio* pPIO_Rs, uint32_t dwPin_Rs )
|
||||
extern uint32_t SN65HVD234_SetRs( SSN65HVD234_Data* pComponent, uint32_t dwPin_Rs )
|
||||
{
|
||||
pComponent->pPIO_Rs=pPIO_Rs ;
|
||||
pComponent->dwPin_Rs=dwPin_Rs ;
|
||||
|
||||
PIO_SetOutput( pPIO_Rs, dwPin_Rs, 0, 0, 1 ) ;
|
||||
pinMode( dwPin_Rs, OUTPUT ) ;
|
||||
|
||||
return 0u ;
|
||||
}
|
||||
@ -83,12 +69,11 @@ extern uint32_t SN65HVD234_SetRs( SSN65HVD234_Data* pComponent, Pio* pPIO_Rs, ui
|
||||
*
|
||||
* \return 0 if OK
|
||||
*/
|
||||
extern uint32_t SN65HVD234_SetEN( SSN65HVD234_Data* pComponent, Pio* pPIO_EN, uint32_t dwPin_EN )
|
||||
extern uint32_t SN65HVD234_SetEN( SSN65HVD234_Data* pComponent, uint32_t dwPin_EN )
|
||||
{
|
||||
pComponent->pPIO_EN=pPIO_EN ;
|
||||
pComponent->dwPin_EN=dwPin_EN ;
|
||||
|
||||
PIO_SetOutput( pPIO_EN, dwPin_EN, 0, 0, 1 ) ;
|
||||
pinMode( dwPin_EN, OUTPUT ) ;
|
||||
|
||||
return 0u ;
|
||||
}
|
||||
@ -103,7 +88,7 @@ extern uint32_t SN65HVD234_SetEN( SSN65HVD234_Data* pComponent, Pio* pPIO_EN, ui
|
||||
extern uint32_t SN65HVD234_Enable( SSN65HVD234_Data* pComponent )
|
||||
{
|
||||
// Raise EN of SN65HVD234 to High Level (Vcc)
|
||||
pComponent->pPIO_EN->PIO_SODR=pComponent->dwPin_EN ;
|
||||
digitalWrite( pComponent->dwPin_EN, HIGH ) ;
|
||||
|
||||
return 0u ;
|
||||
}
|
||||
@ -118,7 +103,7 @@ extern uint32_t SN65HVD234_Enable( SSN65HVD234_Data* pComponent )
|
||||
extern uint32_t SN65HVD234_Disable( SSN65HVD234_Data* pComponent )
|
||||
{
|
||||
// Lower EN of SN65HVD234 to Low Level (0.0v)
|
||||
pComponent->pPIO_EN->PIO_CODR=pComponent->dwPin_EN ;
|
||||
digitalWrite( pComponent->dwPin_EN, LOW ) ;
|
||||
|
||||
return 0u ;
|
||||
}
|
||||
@ -133,7 +118,7 @@ extern uint32_t SN65HVD234_Disable( SSN65HVD234_Data* pComponent )
|
||||
extern uint32_t SN65HVD234_EnableLowPower( SSN65HVD234_Data* pComponent )
|
||||
{
|
||||
// Raise Rs of SN65HVD234 to more than 0.75v
|
||||
pComponent->pPIO_Rs->PIO_SODR=pComponent->dwPin_Rs ;
|
||||
digitalWrite( pComponent->dwPin_Rs, HIGH ) ;
|
||||
|
||||
// Now, SN65HVD234 is only listening
|
||||
|
||||
@ -150,7 +135,7 @@ extern uint32_t SN65HVD234_EnableLowPower( SSN65HVD234_Data* pComponent )
|
||||
extern uint32_t SN65HVD234_DisableLowPower( SSN65HVD234_Data* pComponent )
|
||||
{
|
||||
// Lower Rs of SN65HVD234 to 0.0v < 0.33v
|
||||
pComponent->pPIO_Rs->PIO_CODR=pComponent->dwPin_Rs ;
|
||||
digitalWrite( pComponent->dwPin_Rs, LOW ) ;
|
||||
|
||||
return 0u ;
|
||||
}
|
||||
|
@ -1,31 +1,21 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2010, Atmel Corporation
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "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 ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2013 Arduino. All right reserved.
|
||||
|
||||
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 St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
@ -44,20 +34,16 @@
|
||||
|
||||
typedef struct _SSN65HVD234_Data
|
||||
{
|
||||
/** PIO dedicated to Rs pin */
|
||||
Pio* pPIO_Rs ;
|
||||
/** Rs Pin on PIO */
|
||||
uint32_t dwPin_Rs ;
|
||||
|
||||
/** PIO dedicated to EN pin */
|
||||
Pio* pPIO_EN ;
|
||||
/** EN Pin on PIO */
|
||||
uint32_t dwPin_EN ;
|
||||
} SSN65HVD234_Data ;
|
||||
|
||||
extern uint32_t SN65HVD234_Init( SSN65HVD234_Data* pComponent ) ;
|
||||
extern uint32_t SN65HVD234_SetRs( SSN65HVD234_Data* pComponent, Pio* pPIO_Rs, uint32_t dwPin_Rs ) ;
|
||||
extern uint32_t SN65HVD234_SetEN( SSN65HVD234_Data* pComponent, Pio* pPIO_EN, uint32_t dwPin_EN ) ;
|
||||
extern uint32_t SN65HVD234_SetRs( SSN65HVD234_Data* pComponent, uint32_t dwPin_Rs ) ;
|
||||
extern uint32_t SN65HVD234_SetEN( SSN65HVD234_Data* pComponent, uint32_t dwPin_EN ) ;
|
||||
|
||||
extern uint32_t SN65HVD234_Enable( SSN65HVD234_Data* pComponent ) ;
|
||||
extern uint32_t SN65HVD234_Disable( SSN65HVD234_Data* pComponent ) ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user