Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102222564
port.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 18, 10:42
Size
2 KB
Mime Type
text/x-c
Expires
Thu, Feb 20, 10:42 (2 d)
Engine
blob
Format
Raw Data
Handle
24283316
Attached To
R6617 Oncilla SBCP Master Firmware
port.c
View Options
/*
port.c
Copyright (C) 2010 Rico Moeckel <rico.moeckel at epfl dot ch>,
EPFL Biorobotics Laboratory (http://biorob.epfl.ch)
EPFL Ecole Polytechnique Federale de Lausanne (http://www.epfl.ch)
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 <http://www.gnu.org/licenses/>.
*/
/**
\defgroup port PORT
\brief Port initialization.
This module is responsible for the initialization of the microcontroller's ports. This includes
setting for direction, special programmable pins connected to peripheries like UART
and inital values as well as defines to ease access to the ports.
Keep in mind that further pin initialization might be done
locally in files dealing with special peripheries like ADC, PWM etc.
\author Rico Moeckel
\version 1.0
\date 2010-08-21
*/
/*@{*/
/** \file port.c
\brief Port initialization file.
*/
#include "port.h"
#include <p33Fxxxx.h>
/*************************************************************************
*
* FUNCTIONS
*
*************************************************************************/
/** \brief Initialization function for ports of the microcontroller
This function configures and initializes the ports of the microcontroller.
It initializes the two UART ports for the RS485 bus and USB-to-RS232 converter
and disables the communication with the possible Bluetooth device.
\param no parameters
\return no returns
*/
void port_init()
{
// --------------- Pin default configuration ---------------------------------------------------------
ADPCFG = 0xffff; // Set all Analog ports as Digital I/O
TRISA = 0xffff; // Everything is input
TRISB = 0xffff; // Everything is input
_TRISA0 = 0; // set LEDB (Green led to output)
_TRISA1 = 0; // set LEDC (Red LED) to output
_TRISB14 = 0; // set LEDG (Green led) to output
_TRISB15 = 0; // set LEDA (Yellow) to output
_TRISB6 = 0; // set Receiver Enable to output
_TRISB7 = 0; // set Driver Enable to output
//PORT_BT_RESET = 0;
//PORT_BT_TXD = 1;
//PORT_BT_RTS = 1;
//------------- UART1 connect to RS485 --------------------------
_U1RXR = 5; // Map UART1 RX to port RP5
_RP8R = 3; // Map UART1 TX to RP8
//------------- UART2 connect to USB-to-RS232 converter ---------
_U2RXR = 12; // Map UART2 RX to port RP12
_RP13R = 5; // Map UART2 TX to RP13
}
/*@}*/
Event Timeline
Log In to Comment